<?php
$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){
        $("#ImageForm").TWS_Form( {
          validate : {
          rules : {
            wym_img_select : {required : true}
          }
          },
          ajaxForm : {
            type : "POST",
            dataType : "json",
            data : {value1 : "Test value passed"},
             success : function(response, statusText, xhr, elem) {
              if (response.fileUploaded) {
                $.TWS_Overlay("success",{message : "File was successfully uploaded:  <a href=\"" + response.fileUploaded + "\">Link</a>"});
              } else {
                $.TWS_Overlay("error",{message : "File was not successfully uploaded."});
              }
             },
            error : function (response) {
              $.TWS_Overlay("error",{message : "Error occurred."});
            },
            resetForm : true,
            clearForm : true,
            iframe : true
          }

        });
        });
       ';
$this->Html->scriptEnd();
?>
<h1>Image Upload</h1>
<form method="post" enctype="multipart/form-data" id="ImageForm" name="ImageForm" action="<?php echo $this->Html->url(array("action"=>"uploadWYMContentImage"));?>"  class="inlineForm">

  <div class="row">
    <label for="wym_img_url"> Select image
      <input type="file" id="wym_img_select" name="wym_img_select"/>
    </label>
  </div>
  <div class="row">
  <input type="submit" id="submitBtn" name="submitBtn" value="submit"/>
  </div>
</form>